<template>
  <div class="Rolemg">
    <section class="toolTop">
      <el-form :inline="true" class="demo-form-inline">
        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item class="addBtn">
              <el-button icon="el-icon-plus" v-on:click="handleDialog = true">新 增 角 色</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </section>
    <section class="main_table">
      <el-table
        ref="multipleTable"
        v-bind:data="roleData"
        style="width: 100%"
        v-bind:max-height="height"
        v-bind:header-cell-style="{background: '#1f2548',color:'#ffffff'}"
        v-bind:cell-style="{padding:'5px',}"
        v-on:row-dblclick="rowClick"
        @selection-change="handleSelectionChange"
        fit
      >
        <el-table-column align="center" type="selection" max-width="120"></el-table-column>
        <el-table-column align="center" prop="roleName" label="角色名称" max-width="120"></el-table-column>
        <el-table-column align="center" prop="description" label="说明" max-width="120"></el-table-column>
        <el-table-column align="center" prop="createDate" label="创建时间" max-width="120"></el-table-column>
        <el-table-column align="center" label="操作" max-width="120">
          <template slot-scope="scope">
            <el-button type="danger" size="small" @click.native.prevent="deleteRow(scope.row)">
              删除
            </el-button>
            <el-button
              @click.native.prevent="rowClick(scope.row,'set')"
              type="primary"
              size="small"
            >
              菜单配置
            </el-button>
            <el-button
              @click.native.prevent="rowClick(scope.row, 'modify')"
              type="primary"
              size="small"
            >
              编辑
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <section class="toolFoot">
        <el-row :gutter="25">
          <el-col :span="24" class="rightCol">
            <el-pagination
              small
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[5, 10, 15, 20]"
              :page-size="pagesize"
              layout="total, sizes, prev, pager, next ,jumper"
              :total="total"
              :pager-count="5"
            ></el-pagination>
          </el-col>
        </el-row>
      </section>
    </section>
    <section class="dialogSec" v-bind:class="{'dialogshow': handleDialog}">
      <el-form size="mini" label-position="right" :model="form">
        <section class="title">
          <h3>角色设置</h3>
          <i class="el-icon-close" @click="handleDialog = false"></i>
        </section>
        <section class="top">
          <el-form-item label="角色名称" :label-width="formLabelWidth">
            <el-input v-model="form.name" v-bind:disabled="formDisabled"></el-input>
          </el-form-item>
          <el-form-item label="角色描述" :label-width="formLabelWidth">
            <el-input v-model="form.description" v-bind:disabled="formDisabled"></el-input>
          </el-form-item>
        </section>
        <section class="main" v-bind:hidden="menuSet == 0 || menuSet == 1">
          <el-row>
            <el-col :span="8" class="colLeft">
              <div class="wrap">
                <h3>菜单名称</h3>
                <div class="ztreeWrap">
                  <ul id="treeDemo" class="ztree"></ul>
                </div>
              </div>
            </el-col>
            <el-col :span="16" class="colRight">
              <div class="wrap">
                <h3>{{menuName}}功能</h3>
                <div class="operateWrap">
                  <el-checkbox-group
                    v-model="checkedOperate"
                    size="mini"
                    v-on:change="handleCheckBox"
                  >
                    <transition-group v-bind:name="operateCheckActive">
                      <div
                        class="checkbox_wrap"
                        v-for="item in selectOperate"
                        v-bind:key="item.mid"
                        v-show="item.pId === showItem"
                      >
                        <el-checkbox
                          v-if="item.pId === showItem"
                          v-bind:label="item.mid"
                          v-show="item.pId === showItem"
                        >{{item.mName}}</el-checkbox>
                      </div>
                    </transition-group>
                  </el-checkbox-group>
                </div>
              </div>
            </el-col>
          </el-row>
        </section>
        <section class="foot">
          <div slot="footer" class="dialog-footer">
            <el-button size="mini" @click="handleDialog = false">取 消</el-button>
            <el-button
              size="mini"
              type="success"
              @click="subAdd"
              v-bind:hidden="menuSet != 0"
            >提 交 新 增</el-button>
            <el-button
              size="mini"
              type="primary"
              @click="subModify"
              v-bind:hidden="menuSet != 1"
            >提 交 修 改</el-button>
            <el-button
              size="mini"
              type="primary"
              @click="subSet"
              v-bind:hidden="menuSet != 2"
            >提 交 配 置</el-button>
          </div>
        </section>
      </el-form>
    </section>
  </div>
</template>

<script type="text/javascript" src="../../../api/sysmg/systemconfig/rolemg.js"></script>

<style lang="scss">
.Rolemg {
  flex: 1;
  > section {
    &.toolTop {
      height: auto !important;
      padding-bottom: 5px;
      > .el-form {
        border-radius: 5px;
        padding: 8px 16px;
        .el-form-item {
          margin-bottom: 0;
          .el-button {
            background-color: #161836;
            font-size: 14px;
            padding: 8px 16px;
            color: #85899c;
            border: 1px solid #85899c;
          }
          .el-button:hover,
          .el-button:focus {
            background-color: #161836;
            font-size: 14px;
            padding: 8px 16px;
            color: #fff;
            border: 1px solid #fff;
          }
        }
      }
    }
    &.main_table {
      border-radius: 5px;
      padding: 14px;
      margin-bottom: 16px;
      .cell {
        .el-button--primary {
          color: #85899c;
          background-color: #161836;
          border: 1px solid #85899c;
        }
        .el-button--primary:focus,
        .el-button--primary:hover {
          color: #ffffff;
          background-color: #44abf5;
          border: 1px solid #44abf5;
        }
      }
      > .toolFoot {
        margin-top: 16px;
        .rightCol {
          text-align: right;
          .el-pagination--small {
            white-space: nowrap;
            padding: 2px 5px;
            color: #303133;
            font-weight: 700;
            height: 50px;
            span {
              color: #fff;
              line-height: 30px;
              .el-input {
                .el-input__inner {
                  height: 30px;
                  line-height: 30px;
                }
              }
            }
          }
        }
      }
    }

    &.dialogSec {
      > .el-form {
        > section {
          &.top {
            .el-form-item {
              margin: 16px 0 0 0;
            }
          }
          &.main {
            > .el-row {
              border: 1px solid #e8e8e8;
              .el-col {
                .wrap {
                  h3 {
                    background-color: #e8e8e8;
                    font-size: 2rem;
                    text-align: center;
                    padding: 4px 0;
                    color: #000;
                  }
                }
                .ztreeWrap {
                  max-height: 50vh;
                  overflow: auto;
                  padding: 16px;
                }
                &.colLeft {
                  border-right: 8px solid #e3e3e3;
                }
                &.colRight {
                  .operateWrap {
                    padding: 0px 16px;
                    .checkbox_wrap {
                      padding: 5px 10px;
                    }
                  }
                }
              }
            }
          }
        }
        .foot {
          .el-button--default {
            background-color: #161836;
            font-size: 14px;
            padding: 8px 16px;
            color: #85899c;
            border: 1px solid #85899c;
          }
          .el-button--default:hover,
          .el-button--default:focus {
            background-color: #161836;
            font-size: 14px;
            padding: 8px 16px;
            color: #fff;
            border: 1px solid #fff;
          }
          .el-button--success {
            padding: 8px 16px;
            font-size: 14px;
            background-color: #44abf5;
            border: 1px solid #44abf5;
            color: #fff;
          }
          .el-button--primary {
            padding: 8px 16px;
            font-size: 14px;
            background-color: #44abf5;
            border: 1px solid #44abf5;
            color: #fff;
          }
        }
      }
    }
  }
}
</style>
